/*
 * ViewDomain.java
 * @author Andrey Tesler
 * Created for DiffView project
 * Created on 4 October 2009, 13:54
 */

package diffview.gui;

import java.util.*;
import java.io.*;
import static java.lang.Math.*;
import static java.lang.System.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import diffview.*;

public class ViewDomain extends /*JComponent*/ JPanel {
    
    private IModel model;
    DiffTextArea oldLines, newLines;
    JSplitPane splitPane;
    
//    public ViewDomain() {
//        this(new DiffTextArea(), new DiffTextArea());
//    }
    
    public ViewDomain(/*DiffTextArea oldLines, DiffTextArea newLines*/) {
        super();
        model = new Model();
        oldLines = new DiffTextArea();
        newLines = new DiffTextArea();
////        try {
////            model = Main.createModel(oldLines.getText(), newLines.getText());
////        } catch (IOException ex) {
////            out.println(ex);
////        }
        //setSize(700, 500);
        //setPreferredSize(new Dimension(700, 500));
        splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
                new JScrollPane(oldLines),
                new JScrollPane(newLines));
        splitPane.setDividerLocation(0.5);
        splitPane.setResizeWeight(0.5); // the divider remains in the middle
        splitPane.setOneTouchExpandable(true);
        //splitPane.setSize(700, 500);
        add(splitPane, BorderLayout.CENTER);
    }
    
    public void paintComponent(Graphics g) {
        
        oldLines.setText(model.getOldLines());
        newLines.setText(model.getNewLines());
    }
    
    public void setModel(IModel model) {
        this.model = model;
    }
    public IModel getModel() {
        return model;
    }
}
